<style lang='scss' scoped>
.view1 {
    .nav {
        display: flex;
        justify-content: space-between;
        margin-top: 0.8rem;
        .nav_left,
        .nav_right {
            width: 48%;
            position: relative;

            image {
                width: 100%;
            }

            .nav_left_text {
                position: absolute;
                top: 30%;
                left: 6%;
                color: #fff;
                width: 100%;
                .nav_left_text_t {
                    font-size: 0.9rem;
                }
                .nav_left_text_b {
                    margin-top: 0.2rem;
                    font-size: 0.6rem;
                }
            }
        }
    }
    .duanju_title {
        display: flex;
        align-items: center;
        margin-top: 0.8rem;
        margin-bottom: 0.5rem;
        .text {
            font-size: 1rem;
            font-weight: 600;
        }
        image {
            width: 1.5rem;
        }
    }
    .listsForRecommend,
    .listsForNew,
    .listsForHot {
        display: flex;
        .row_list {
            margin-right: 0.5rem;
            .row_list_top_image {
                width: 6rem;
                height: 9rem;
                border-radius: 0.5rem;
            }
            .row_list_content_name {
                width: 6rem;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
                font-size: 0.6rem;
            }
            .row_list_content_image {
                image {
                    width: 0.8rem;
                    margin-right: 0.2rem;
                }
            }
            .row_list_content_num {
                font-size: 0.5rem;
            }
        }
    }
    .sticky_box {
        padding: 1rem 0;
    }
    .stickychangeflag {
        background-color: #fcf2e0;
        width: 100vw;
        position: fixed;
        top: 0;
        left: 0;
        padding: 0.8rem;
    }
    .footer_list {
        .list {
            display: flex;
            justify-content: space-between;
            background-color: #fff;
            margin-bottom: 0.5rem;
            padding: 0.8rem;
            border-radius: 0.2rem;
            align-items: center;
            height: 8rem;
            .left {
                width: 4rem;
                margin-right: 0.5rem;
                height: 100%;
                image {
                    width: 4rem;
                    border-radius: 0.2rem;
                    height: 100%;
                }
            }
            .center {
                height: 100%;
                flex: 1;
                display: flex;
                flex-direction: column;
                justify-content: space-between;
                padding: 0.2rem 0;
                .a {
                    display: flex;
                    align-items: baseline; // 基线对齐
                    .name {
                        font-size: 1rem;
                        margin-right: 0.5rem;
                        width: 6rem;
                        overflow: hidden;
                        text-overflow: ellipsis;
                        white-space: nowrap;
                    }
                    .jishu {
                        font-size: 0.8rem;
                    }
                }
                .b {
                    display: flex;
                    align-items: center;
                    image {
                        width: 0.8rem;
                        margin-right: 0.2rem;
                    }
                    font-size: 0.8rem;
                }
                .c {
                    color: #7b9df7;
                    font-size: 0.8rem;
                }
                .d {
                    text {
                        font-size: 0.7rem;
                        background-color: #fef0d6;
                        color: #fba061;
                        padding: 0.2rem 0.5rem;
                        border-radius: 0.2rem;
                    }
                }
            }
            .right {
                width: 4rem;
                .right_button {
                    width: 4rem;
                    height: 1.8rem;
                    font-size: 0.8rem;
                    background: linear-gradient(
                        270deg,
                        #fa7563 0%,
                        #fa924d 100%
                    );
                    color: white !important;
                    border-radius: 8rpx;
                    align-items: center;
                    justify-content: center;
                    display: flex;
                }
            }
        }
        .footer——text {
            text-align: center;
        }
    }
}
</style>

<template>
    <view class="view1">
        <!-- 轮播图 -S -->
        <u-swiper :list="state.bananerArr" @click="goPath" border-radius="16"></u-swiper>
        <!-- 轮播图 -E -->
        <!-- 导航栏 -S -->
        <view class="nav">
            <view class="nav_left" @click="goposter">
                <image src="../../static/images/index/recruit.png" mode="widthFix" />
                <view class="nav_left_text">
                    <view class="nav_left_text_t">邀请实力团队长</view>
                    <view class="nav_left_text_b">得最高33%返佣</view>
                </view>
            </view>
            <view class="nav_right" @click="goPathinvite">
                <image src="../../static/images/index/income.png" mode="widthFix" />
                <view class="nav_left_text">
                    <view class="nav_left_text_t">邀请会员</view>
                    <view class="nav_left_text_b">无上限分佣奖励</view>
                </view>
            </view>
        </view>
        <!-- 导航栏 -E -->
        <!-- 爆款精品 -S -->
        <view class="duanju_title">
            <view class="text">爆款精品</view>
            <image src="../../static/images/index/boutique.png" mode="widthFix" />
        </view>
        <scroll-view scroll-x @touchmove.stop>
            <view class="listsForHot">
                <view class="row_list" v-for="(item, index) in state.listsForHot" :key="index" @click="gosketch(item)">
                    <image class="row_list_top_image" :src="item.image_cover || '../../static/images/icon/loading.gif'" />
                    <view class="row_list_content">
                        <view class="row_list_content_name">{{ item.name || "" }}</view>
                        <view class="row_list_content_image">
                            <image v-if="item.is_share_douyin" src="../../static/images/index/douyinIcon.png" mode="widthFix" />
                            <image v-if="item.is_share_kuaishou" src="../../static/images/index/kuaishouIcon.png" mode="widthFix" />
                            <image v-if="item.is_share_h5" src="../../static/images/index/siyuIcon.png" mode="widthFix" />
                            <image v-if="item.is_share_wechat" src="../../static/images/index/weixinIcon.png" mode="widthFix" />
                        </view>
                        <view class="row_list_content_num">{{ item.share_num || "" }}人推广</view>
                    </view>
                </view>
            </view>
        </scroll-view>
        <!-- 爆款精品 -E -->
        <!-- 最新上架 -S -->
        <view class="duanju_title" @touchmove.stop>
            <view class="text">最新上架</view>
            <image src="../../static/images/index/nuew.png" mode="widthFix" />
        </view>
        <scroll-view scroll-x @touchmove.stop>
            <view class="listsForNew">
                <view class="row_list" v-for="(item, index) in state.listsForNew" :key="index" @click="gosketch(item)">
                    <image class="row_list_top_image" :src="item.image_cover || '../../static/images/icon/loading.gif'" />
                    <view class="row_list_content">
                        <view class="row_list_content_name">{{ item.name || "" }}</view>
                        <view class="row_list_content_image">
                            <image v-if="item.is_share_douyin" src="../../static/images/index/douyinIcon.png" mode="widthFix" />
                            <image v-if="item.is_share_kuaishou" src="../../static/images/index/kuaishouIcon.png" mode="widthFix" />
                            <image v-if="item.is_share_h5" src="../../static/images/index/siyuIcon.png" mode="widthFix" />
                            <image v-if="item.is_share_wechat" src="../../static/images/index/weixinIcon.png" mode="widthFix" />
                        </view>
                        <view class="row_list_content_num">{{ item.share_num || "" }}人推广</view>
                    </view>
                </view>
            </view>
        </scroll-view>
        <!-- 最新上架 -E -->
        <!-- 新手必推 -S -->
        <view class="duanju_title" @touchmove.stop>
            <view class="text">新手必推</view>
            <image src="../../static/images/index/novice.png" mode="widthFix" />
        </view>
        <scroll-view scroll-x @touchmove.stop>
            <view class="listsForRecommend">
                <view class="row_list" v-for="(item, index) in state.listsForRecommend" :key="index" @click="gosketch(item)">
                    <image class="row_list_top_image" :src="item.image_cover || '../../static/images/icon/loading.gif'" />
                    <view class="row_list_content">
                        <view class="row_list_content_name">{{ item.name || "" }}</view>
                        <view class="row_list_content_image">
                            <image v-if="item.is_share_douyin" src="../../static/images/index/douyinIcon.png" mode="widthFix" />
                            <image v-if="item.is_share_kuaishou" src="../../static/images/index/kuaishouIcon.png" mode="widthFix" />
                            <image v-if="item.is_share_h5" src="../../static/images/index/siyuIcon.png" mode="widthFix" />
                            <image v-if="item.is_share_wechat" src="../../static/images/index/weixinIcon.png" mode="widthFix" />
                        </view>
                        <view class="row_list_content_num">{{ item.share_num || "" }}人推广</view>
                    </view>
                </view>
            </view>
        </scroll-view>
        <!-- 新手必推 -E -->
        <!-- 搜索栏 -S -->
        <u-sticky offset-top="0" @stickychange="stickychange">
            <view class="sticky_box" :class="state.stickychangeflag ? 'stickychangeflag animate__animated animate__fadeInUp' : ''">
                <u-navbar-s v-if="state.stickychangeflag"></u-navbar-s>
                <seachall @search="search" :placeholder="'请输入剧名搜索'"></seachall>
                <seachfilter @seachfiltertabs="seachfiltertabs"></seachfilter>
            </view>
        </u-sticky>
        <!-- 搜索栏 -E -->
        <!-- 底部列表 -S -->
        <view class="footer_list">
            <view class="list" v-for="(item, index) in searchSketchArr" :key="index">
                <view class="left">
                    <image :src="item.image_cover || '../../static/images/icon/loading.gif'" />
                </view>
                <view class="center">
                    <view class="a">
                        <view class="name">{{ item.name || "" }}</view>
                        <view class="jishu">{{ item.assemble || "" }}集</view>
                    </view>
                    <view class="b">
                        <image v-if="item.is_share_douyin" src="../../static/images/index/douyinIcon.png" mode="widthFix" />
                        <image v-if="item.is_share_kuaishou" src="../../static/images/index/kuaishouIcon.png" mode="widthFix" />
                        <image v-if="item.is_share_h5" src="../../static/images/index/siyuIcon.png" mode="widthFix" />
                        <image v-if="item.is_share_wechat" src="../../static/images/index/weixinIcon.png" mode="widthFix" />
                        <text>{{ item.share_num || "" }}人推广</text>
                    </view>
                    <view class="c">{{ item.theaterUpstreamApp.title || "" }}</view>
                    <view class="d">
                        <text>历史收益最高： {{ item.max_pay_num }}元</text>
                    </view>
                </view>
                <view class="right">
                    <u-button class="right_button" hover-class="none" @click="gosketch(item)">推广</u-button>
                </view>
            </view>
            <view class="footer——text" v-if="searchSketchArr">{{ searchSketchArr.length < 30 ? "没有更多了" : "正在加载中..." }}</view>
        </view>
        <!-- 底部列表 -E -->
    </view>
</template>

<script setup lang='ts'>
import { reactive, ref } from "vue";
import { onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app";
import { searchSketch } from "@/api/index";
import seachall from "@/components/seachall/seachall.vue";
import seachfilter from "@/components/seachfilter/seachfilter.vue";
components: {
    seachall;
    seachfilter;
}
const props = defineProps({
    searchSketchArr: {
        type: Array,
        default: [],
    },
});
const state = reactive<{
    bananerArr: Array;
    listsForHot: Array;
    listsForNew: Array;
    listsForRecommend: Array;
    stickychangeflag: boolean;
}>({
    stickychangeflag: false,
    listsForRecommend: [],
    listsForNew: [],
    listsForHot: [],
    bananerArr: [],
});

// 本地数据
const localData = () => {
    const bannerlist = uni.getStorageSync("bannerlist") || [];
    state.bananerArr = bannerlist || [];
    const listsAllData = uni.getStorageSync("listsAllData") || [];
    state.listsForHot = listsAllData.listsForHot || [];
    state.listsForNew = listsAllData.listsForNew || [];
    state.listsForRecommend = listsAllData.listsForRecommend || [];
};
const goPath = () => {};
//吸顶
const stickychange = (val) => {
    state.stickychangeflag = val || false;
};
// 点击搜索
const search = (seachVal) => {
    console.log("seachVal:", seachVal);
};
// 点击筛选
const seachfiltertabs = (index) => {
    console.log("index:", index);
};
// 跳转详情
const gosketch = (item) => {
    uni.navigateTo({
        url: `/pages/sketch/detail?id=${item.id}`,
    });
};

//跳转 poster
const goposter = () => {
    uni.navigateTo({
        url: `/pages/poster/poster`,
    });
};
//跳转 invite 邀请会员
const goPathinvite = () => {
    uni.navigateTo({
        url: `/pages/invite/invite`,
    });
};
// 暴露方法
defineExpose({ localData });
</script>